function request(param) {
    return new Promise((resolve) => {
        setTimeout(() => {
            resolve()
            param.data = param.index + '结果'
            console.log('param', param)
        }, 200);
    })
}
function startLimit(paramArr = [], request = async () => { }, num = 5, callback = () => { }) {
    let recusion = (resolve) => {
        if (paramArr.length == 0) {
            return resolve()
        }
        let param = paramArr.shift()
        request(param).then(res => {
            param.data = res
            recusion(resolve)
        })
    }
    Promise.all(Array.from({ length: num }, (v, index) => {
        return new Promise((resolve, reject) => {
            recusion(resolve)
        })
    })).then(() => {
        callback()
    })
}
startLimit(requestArr, request, 5, (res) => {
    console.log('1111', 1111)
})